/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao.interfacce;

import Bean.MeasureData;
import Bean.Vineyard;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mimmo
 */
public class OenologistDAO_DB implements OenologistDAO {

    Connection connection;

    public OenologistDAO_DB(String connectionString, String username, String password) throws Exception {
        connection = DriverManager.getConnection(connectionString, username, password);
    }

    public List<MeasureData> cellarMonitoring(int cl_id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<MeasureData> monitoringParameters(int cl_id, Date data_in, Date data_out) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<MeasureData> monitoringWineRecived(int cl_id, Date data_in, Date data_out) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Vineyard infoVineyard(int v_id) {
        Vineyard vineyard = new Vineyard();

        PreparedStatement ps;
        try {
            ps = connection.prepareStatement("Call infoVineyard(?)");
            ps.setInt(1, v_id);
            ResultSet r = ps.executeQuery();
            while (r.next()) {
                vineyard.setDistrict(r.getString("district"));
                vineyard.setFraction(r.getString("fraction"));
                vineyard.setHectares(r.getInt("hectares"));
                vineyard.setMunicipality(r.getString("municipality"));
                vineyard.setV_id(r.getInt("v-id"));
                vineyard.setZone(r.getString("zone"));

            }
        } catch (SQLException ex) {
            Logger.getLogger(AgronomousDAO_DB.class.getName()).log(Level.SEVERE, null, ex);
        }

        return vineyard;
    }

    public void storeHarvest(int h_id, int v_id, String note, Date date) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
